//
//  Match.h
//  Soccer
//
//  Created by Hyun-Woong Kim on 09. 04. 29.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Stadium.h"
#import "MiniMap.h"
#import "Player.h"
#import "Ball.h"
#import "GoalKeeper.h"
#import "Constant.h"

@protocol MatchDelegate

- (void)objectAdded:(Object *)object;
//- (void)playerAdded:(Player *)player;
//- (void)ballAdded:(Ball *)ball;

@end

/**
 경기 정보
*/
@interface Match : NSObject <UIAccelerometerDelegate>
{
	id<MatchDelegate> _delegate;
	
	CGPoint screenOrientation;
	CGPoint cameraPosition;
	Stadium *stadium_;
	MiniMap *miniMap_;
	Ball *ball_;
	NSMutableArray *players;
	Player *myself;
	
	// 시간 표시
	UITextView* gameTimeView;
	
	// 기술 처리
	int shakedNum;
	NSDate* initDate;	
	
	// 골 표시
	int goal_teamA;
	int goal_teamB;
	UITextView* goalView;
	
	UITextView* latencyView;
}

@property(assign) Stadium *stadium;
@property(assign) MiniMap *miniMap;
@property(nonatomic,retain) Player *myself;
@property(nonatomic,assign) id<MatchDelegate> delegate;
@property(assign) NSMutableArray *players;
@property(assign) int shakedNum;
@property(nonatomic,retain) NSDate* initDate;
@property(assign) Ball *ball_;
@property(readonly) int goal_teamA;
@property(readonly) int goal_teamB;

//- (id)initWithMyself:(Player *)player;

- (Stadium *)getStadium;
- (void)setStadium:(Stadium *)stadium;
- (MiniMap *)getMinimap;
- (void)setMiniMap:(MiniMap *)miniMap;
- (void)addObject:(Object *)object;
- (void)addPlayer:(Player *)player;
- (void)setBall:(Ball *)ball;

- (CGPoint)checkOutline:(CGPoint)position;
- (void)adjustCameraPosition:(CGPoint)playerPosition;
- (CGPoint)getCameraPosition;

- (CGPoint) getPlayerPositionAt:(int)index;
- (double) getPlayerDirectionAt:(int)index;
- (PlayerStatus) getPlayerStatusAt:(int)index;

- (CGPoint) getBallPosition;
- (double) getBallDirection;
- (int) getBallOwner;
- (int) getBallShooter;
- (NSTimeInterval)getBallShootTime;

- (int) getGoalA;
- (int) getGoalB;

- (void) setPlayerPositionX:(float)x Y:(float)y At:(int)index;
- (void) setPlayerDirection:(double)dir At:(int)index;
- (void) setPlayerStatus:(PlayerStatus)status At:(int)index;
- (void) setBallPositionX:(float)x Y:(float)y;
- (void) setBallDirection:(double)dir;
- (void) setBallOwner:(int)index;
- (void) setBallShooter:(int)index;


- (void) setGameTime:(int)frame_number;
- (void) setGoalIn:(int)goal;
- (void) setLatencyTime:(unsigned long)time frameNumber:(int)fn;


@end
